#include <stdio.h>
#include <assert.h>
#include <stdint.h>
#include <limits.h>

int signed_high_prod(int x, int y){
    int64_t high_prod = (int64_t)x * y;
    return (int) (high_prod >> 32);
}

unsigned unsigned_high_prod(unsigned x, unsigned y){

    int mul = signed_high_prod(x, y);
    unsigned mask = (unsigned) INT_MIN;

    return ((0 - !!(x & mask)) & y) + ((0 - !!(y & mask)) & x) + mul;
}

unsigned answer(unsigned x, unsigned y){
    uint64_t high_prod = (uint64_t)x * y;
    return (unsigned) (high_prod >> 32);
}


int main(){

    assert(unsigned_high_prod(0xFFFFFFFF, 2) == 0x1);
    assert(unsigned_high_prod(0xFFFFFFFF, 0x12345678) == answer(0xFFFFFFFF, 0x12345678));

    return 0;
}
